Conversation
JunichiIto
reviewed
Aug 15, 2022
| @@ -1,4 +1,3 @@ | |||
| #!/usr/bin/env ruby | |||
| print_l_option_files(file_stats) | ||
| else | ||
| print_no_option_files(file_stats) | ||
| print_not_l_option_files(file_stats) |
There was a problem hiding this comment.
man lsで-lの説明を読んでみてください。
たぶんlはlong formatのlだと説明されているはずです。
なので、メソッド名もprint_in_long_format、print_in_short_formatみたいにすると対称性があって良いかもしれません。(好みの問題です)
|
|
||
| def make_file_stats(ls_dir) | ||
| files = fetch_files(ls_dir) | ||
| def make_file_stats(ls_dir, params) |
There was a problem hiding this comment.
「オブジェクトを作る」の「作る」はmakeよりもbuildが使われることが多いので、ここもbuild_xxxにした方がいいかも
| files = if params['a'] | ||
| Dir.glob("#{ls_dir}/*", File::FNM_DOTMATCH).sort | ||
| else | ||
| Dir.glob("#{ls_dir}/*").sort |
There was a problem hiding this comment.
flagのデフォルト値は数値の0のようです。
https://docs.ruby-lang.org/ja/latest/method/Dir/s/=5b=5d.html
なので、
flags = params['a'] ? File::FNM_DOTMATCH : 0のようにすると、ここのコードがよりDRYにできそうです
あと、前回紹介したFile.joinを使ってパスを連結してみてください〜。
| if params['r'] | ||
| files.reverse | ||
| else | ||
| files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
lコマンドの -r,-a,-l のオプションに対応しましたので、確認お願いいたします。